package md.lanjing.com.module_mine.contact;

import android.content.Context;


import com.lxh.baselibray.mvp.BasePresent;
import com.lxh.baselibray.mvp.IBaseView;
import com.lxh.baselibray.net.NetCallBack;
import com.lxh.baselibray.net.ServiceGenerator;
import com.lxh.baselibray.util.SPUtils;
import com.lxh.baselibray.util.ToastUtils;


import com.lxh.baselibray.constant.Constant;

import md.lanjing.com.module_mine.bean.PurseAddressRequest;
import md.lanjing.com.module_mine.api.MineApiService;
import md.lanjing.com.module_mine.bean.PurseAddressResponce;
import retrofit2.Call;
import retrofit2.Response;

public class BindPurseContact {
    public static class BindPursePresent extends BasePresent<IBindPurseView> {
        public void bindPurse(final Context context, String purseAddress){
            MineApiService service= ServiceGenerator.createService(MineApiService.class);
            int userId= SPUtils.getInt(Constant.USER_ID,-1,context);
            PurseAddressRequest request=new PurseAddressRequest(userId,purseAddress);
            service.bindPurseAddress(request).enqueue(new NetCallBack<PurseAddressResponce>() {
                @Override
                public void onSuccess(Call<PurseAddressResponce> call, Response<PurseAddressResponce> response) {
                    if (getView()!=null){
                        getView().getBindPurseData( response);
                    }
                }

                @Override
                public void onFailed() {
                    ToastUtils.showLongToast(context,"网络请求异常");
                }
            });
        }
    }
    public interface IBindPurseView extends IBaseView {
        void getBindPurseData(Response<PurseAddressResponce> response);
    }
}
